﻿#Region "License & Usage"

'Microsoft Public License (Ms-PL) 

'This license governs use of the accompanying software. If you use the 
'software, you accept this license. If you do not accept the license, do 
'not use the software. 

'1. Definitions 

'The terms "reproduce," "reproduction," "derivative works," and 
'"distribution" have the same meaning here as under U.S. copyright law. 

'A "contribution" is the original software, or any additions or changes 
'to the software. 

'A "contributor" is any person that distributes its contribution under 
'this license. 

'"Licensed patents" are a contributor's patent claims that read directly 
'on its contribution. 

'2. Grant of Rights 

'(A) Copyright Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free copyright license to 
'reproduce its contribution, prepare derivative works of its 
'contribution, and distribute its contribution or any derivative works 
'that you create. 

'(B) Patent Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free license under its licensed 
'patents to make, have made, use, sell, offer for sale, import, and/or 
'otherwise dispose of its contribution in the software or derivative 
'works of the contribution in the software. 

'3. Conditions and Limitations 

'(A) No Trademark License- This license does not grant you rights to use 
'any contributors' name, logo, or trademarks. 

'(B) If you bring a patent claim against any contributor over patents 
'that you claim are infringed by the software, your patent license from 
'such contributor to the software ends automatically. 

'(C) If you distribute any portion of the software, you must retain all 
'copyright, patent, trademark, and attribution notices that are present 
'in the software. 

'(D) If you distribute any portion of the software in source code form, 
'you may do so only under this license by including a complete copy of 
'this license with your distribution. If you distribute any portion of 
'the software in compiled or object code form, you may only do so under a 
'license that complies with this license. 

'(E) The software is licensed "as-is." You bear the risk of using it. The 
'contributors give no express warranties, guarantees or conditions. You 
'may have additional consumer rights under your local laws which this 
'license cannot change. To the extent permitted under your local laws, 
'the contributors exclude the implied warranties of merchantability, 
'fitness for a particular purpose and non-infringement.

#End Region

#Region "Options"

Option Strict On
Option Explicit On

#End Region

#Region "Imports"

'From .Net Framework 3.5
Imports Microsoft.Drawing
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms

'From Custom Classes/Reference
Imports StedySoft.SenseSDK
Imports StedySoft.SenseSDK.DrawingCE
Imports SenseSDKExtended.DrawingCEEx

#End Region

Namespace SensePanelItemEx

    ''' <summary>SensePanelItemEx.HTCContactsStyle3Options</summary>
    ''' <author>Greenhacks</author>
    ''' <author-reference>None</author-reference>
    ''' <copyright>None</copyright>
    ''' <version>0.1</version>
    ''' <remarks>None</remarks>
    ''' <reference>None</reference>
    <CLSCompliant(True)> _
    Public Class HTCContactsStyle3Options

        ''' <summary>
        ''' ProcessProperties
        ''' </summary>
        ''' <param name="control"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <CLSCompliant(False)> _
        Public Shared Function ProcessProperties(ByVal control As SensePanelItemEx.HTCContactsStyle3) As SenseAPIsEx.SenseControlsManager.PropertyTableValues

            Dim _propertyTableValues = New SenseAPIsEx.SenseControlsManager.PropertyTableValues

            Dim _iThumbnailLeftMarginLR As Integer = If(_isVGA, 20, 10)
            Dim _iThumbnailLeftMarginTB As Integer = If(_isVGA, 20, 10)
            Dim _iThumbnailLeftX As Integer = If(_isVGA, 10, 5)
            Dim _iThumbnailLeftY As Integer = If(_isVGA, 10, 5)
            Dim _iThumbnailLeftW As Integer = If(Not control.iThumbnailLeft Is Nothing, SenseAPIs.SenseImage.GetIImageSize(control.iThumbnailLeft).Width + _iThumbnailLeftMarginLR, If(_isVGA, 10, 5))
            Dim _iThumbnailLeftH As Integer = If(Not control.iThumbnailLeft Is Nothing, SenseAPIs.SenseImage.GetIImageSize(control.iThumbnailLeft).Height, 0)

            Dim _iThumbnailRightMarginLR As Integer = If(_isVGA, 20, 10)
            Dim _iThumbnailRightMarginTB As Integer = If(_isVGA, 20, 10)
            Dim _iThumbnailRightX As Integer = If(_isVGA, 10, 5)
            Dim _iThumbnailRightY As Integer = If(_isVGA, 10, 5)
            Dim _iThumbnailRightW As Integer = If(Not control.iThumbnailRight Is Nothing, SenseAPIs.SenseImage.GetIImageSize(control.iThumbnailRight).Width + _iThumbnailRightMarginLR, If(_isVGA, 10, 5))
            Dim _iThumbnailRightH As Integer = If(Not control.iThumbnailRight Is Nothing, SenseAPIs.SenseImage.GetIImageSize(control.iThumbnailRight).Height, 0)

            Dim _primaryTextMarginTB As Integer = If(_isVGA, 20, 10)
            Dim _primaryTextX As Integer = _iThumbnailLeftW
            Dim _primaryTextY As Integer = If(_isVGA, 10, 5)
            Dim _primaryTextW As Integer = Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftW + _iThumbnailRightW)
            Dim _primaryTextH As Integer = SenseAPIsEx.SenseStrings.CalculateStringHeight(control.PrimaryText, control.PrimaryTextFontName, CInt(control.PrimaryTextFontSize), control.PrimaryTextFontStyle, New Size(_primaryTextW, Nothing))

            Dim _secondaryTextMarginTB As Integer = If(_isVGA, 20, 10)
            Dim _secondaryTextX As Integer = _iThumbnailLeftW
            Dim _secondaryTextY As Integer = _primaryTextH + If(_isVGA, 10, 5)
            Dim _secondaryTextW As Integer = Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftW + _iThumbnailRightW)
            Dim _secondaryTextH As Integer = SenseAPIsEx.SenseStrings.CalculateStringHeight(control.SecondaryText, control.SecondaryTextFontName, CInt(control.SecondaryTextFontSize), control.SecondaryTextFontStyle, New Size(_secondaryTextW, Nothing))

            Dim _footerTextMarginTB As Integer = If(_isVGA, 20, 10)
            Dim _footerTextX As Integer = _iThumbnailLeftW
            Dim _footerTextY As Integer = _primaryTextH + _secondaryTextH + If(_isVGA, 10, 5)
            Dim _footerTextW As Integer = Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftW + _iThumbnailRightW)
            Dim _footerTextH As Integer = SenseAPIsEx.SenseStrings.CalculateStringHeight(control.FooterText, control.FooterTextFontName, CInt(control.FooterTextFontSize), control.FooterTextFontStyle, New Size(_footerTextW, Nothing))

            _propertyTableValues._primaryTextRectangle = New Rectangle(_primaryTextX, _primaryTextY, _primaryTextW, _primaryTextH)
            _propertyTableValues._secondaryTextRectangle = New Rectangle(_secondaryTextX, _secondaryTextY, _secondaryTextW, _secondaryTextH)
            _propertyTableValues._footerTextRectangle = New Rectangle(_footerTextX, _footerTextY, _footerTextW, _footerTextH)

            Dim _biggerThumbnailH As Integer = 0
            If _iThumbnailLeftH > _iThumbnailRightH Then
                _biggerThumbnailH = _iThumbnailLeftH
            Else
                _biggerThumbnailH = _iThumbnailRightH
            End If

            Dim _biggerHeight As Integer = 0
            If (_primaryTextMarginTB + _primaryTextH + _primaryTextMarginTB + _secondaryTextH + _footerTextMarginTB + _footerTextH) > _biggerThumbnailH Then
                _biggerHeight = _primaryTextH + _secondaryTextH + _footerTextH
            Else
                _biggerHeight = _biggerThumbnailH
            End If

            If _biggerHeight > control.Height Then
                _propertyTableValues._size = New Size(Screen.PrimaryScreen.Bounds.Width, _biggerHeight + If(_isVGA, 20, 10))
            Else
                If _biggerHeight < 55 Then
                    If (_biggerThumbnailH + If(_isVGA, 20, 10)) > If(_isVGA, 75, 37) Then
                        _propertyTableValues._size = New Size(Screen.PrimaryScreen.Bounds.Width, _biggerThumbnailH + If(_isVGA, 20, 10))
                    Else
                        _propertyTableValues._size = New Size(Screen.PrimaryScreen.Bounds.Width, If(_isVGA, 75, 37))
                    End If
                Else
                    _propertyTableValues._size = New Size(Screen.PrimaryScreen.Bounds.Width, control.Height) ' + If(_isVGA, 10, 5))
                End If
            End If

            Return _propertyTableValues

        End Function

        ''' <summary>
        ''' Check if it is VGA or QVGA
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <CLSCompliant(False)> _
        Public Shared Function _isVGA() As Boolean

            Try

                'Return the output
                Return StedySoft.SenseSDK.DrawingCE.Resolution.ScreenIsVGA

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Function

    End Class

    ''' <summary>SensePanelItemEx.HTCContactsStyle3</summary>
    ''' <author>Greenhacks</author>
    ''' <author-reference>None</author-reference>
    ''' <copyright>None</copyright>
    ''' <version>0.1</version>
    ''' <remarks>None</remarks>
    ''' <reference>None</reference>
    <CLSCompliant(True)> _
    Public Class HTCContactsStyle3
        Inherits SensePanelBase
        Implements IDisposable

#Region "Fields"

        'General Flags
        Private _disposed As Boolean = False

        'General Properties
        Private _name As String = Nothing
        Private _backColor As System.Drawing.Color = Nothing

        'PrimaryText Properties
        Private _primaryText As String = Nothing
        Private _primaryTextRectangle As Rectangle = Nothing
        Private _primaryTextFontName As String = "Tahoma" '"Helvetica Neue OTS"
        Private _primaryTextFontSize As Single = 9.0F
        Private _primaryTextFontStyle As System.Drawing.FontStyle = FontStyle.Regular
        Private _primaryTextForeColor As System.Drawing.Color = Color.Black
        Private _primaryTextBackColor As System.Drawing.Color = Color.Gray
        Private _primaryTextAlignment As System.Drawing.StringAlignment = StringAlignment.Near

        'SecondaryText Properties
        Private _secondaryText As String = Nothing
        Private _secondaryTextRectangle As Rectangle = Nothing
        Private _secondaryTextFontName As String = "Tahoma" '"Helvetica Neue OTS"
        Private _secondaryTextFontSize As Single = 7.0F
        Private _secondaryTextFontStyle As System.Drawing.FontStyle = FontStyle.Regular
        Private _secondaryTextForeColor As System.Drawing.Color = Color.Black
        Private _secondaryTextBackColor As System.Drawing.Color = Color.Gray
        Private _secondaryTextAlignment As System.Drawing.StringAlignment = StringAlignment.Near

        'FooterText Properties
        Private _footerText As String = Nothing
        Private _footerTextRectangle As Rectangle = Nothing
        Private _footerTextFontName As String = "Tahoma" '"Helvetica Neue OTS"
        Private _footerTextFontSize As Single = 7.0F
        Private _footerTextFontStyle As System.Drawing.FontStyle = FontStyle.Regular
        Private _footerTextForeColor As System.Drawing.Color = Color.Black
        Private _footerTextBackColor As System.Drawing.Color = Color.Gray
        Private _footerTextAlignment As System.Drawing.StringAlignment = StringAlignment.Near

        'Hold Images
        Private _iThumbnailLeft As Microsoft.Drawing.IImage = Nothing
        Private _iThumbnailRight As Microsoft.Drawing.IImage = Nothing

        'Hold Cordinates
        Private _iThumbnailLeftRectangle As Rectangle = Nothing
        Private _iThumbnailRightRectangle As Rectangle = Nothing

        Private _myCurrentPosition As Integer = 0
        Private _propertyTableValues As SenseAPIsEx.SenseControlsManager.PropertyTableValues = Nothing

        'Hold Margins
        Private _iThumbnailLeftMarginLR As Double = 0
        Private _iThumbnailLeftMarginTB As Double = 0
        Private _iThumbnailRightMarginLR As Double = 0
        Private _iThumbnailRightMarginTB As Double = 0

#End Region

#Region "Events"

        ''' <summary>
        ''' OnClick Event
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks>General Control OnClick Event</remarks>
        Public Shadows Event OnClick(ByVal sender As Object)

        ''' <summary>
        ''' OnClickiThumbnailLeft Event
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        Public Event OnClickiThumbnailLeft(ByVal sender As Object)

        ''' <summary>
        ''' OnClickiThumbnailRight Event
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        Public Event OnClickiThumbnailRight(ByVal sender As Object)

        ''' <summary>
        ''' OnClickPrimaryText
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        Public Event OnClickPrimaryText(ByVal sender As Object)

        ''' <summary>
        ''' OnClickSecondaryText
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        Public Event OnClickSecondaryText(ByVal sender As Object)

        ''' <summary>
        ''' OnClickFooterText
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <remarks></remarks>
        Public Event OnClickFooterText(ByVal sender As Object)

        ''' <summary>
        ''' OnControlMoved Event
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="Y"></param>
        ''' <remarks>Fires when a control is scrolled in the list</remarks>
        Public Event OnControlMoved(ByVal sender As Object, ByVal Y As Integer)

#End Region

#Region "Methods"

        ''' <summary>
        ''' Constructor
        ''' </summary>
        ''' <remarks>None</remarks>
        Public Sub New()

            Try

                'Do Nothing

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Sub

        ''' <summary>
        ''' Constructor
        ''' </summary>
        ''' <remarks>None</remarks>
        Public Sub New(ByVal Name As String)

            Try

                'Save name property
                _name = Name

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Sub

        ''' <summary>
        ''' Dispose
        ''' </summary>
        ''' <remarks>None</remarks>
        Public Overrides Sub Dispose()

            Try

                Me._dispose(True)
                GC.SuppressFinalize(Me)
                MyBase.Dispose()

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Sub

        ''' <summary>
        ''' _Dispose
        ''' </summary>
        ''' <param name="disposing"></param>
        ''' <remarks>None</remarks>
        Private Sub _dispose(ByVal disposing As Boolean)

            Try

                Me._disposed = True

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try
        End Sub

        ''' <summary>
        ''' Check if it is VGA or QVGA
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function _isVGA() As Boolean

            Try

                'Return the output
                Return StedySoft.SenseSDK.DrawingCE.Resolution.ScreenIsVGA

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Function

        ''' <summary>
        ''' OnMouseDown Event
        ''' </summary>
        ''' <param name="x"></param>
        ''' <param name="y"></param>
        ''' <param name="cancelScroll"></param>
        ''' <remarks></remarks>
        Public Overrides Sub OnMouseDown(ByVal x As Integer, ByVal y As Integer, ByRef cancelScroll As Boolean)
            MyBase.OnMouseDown(x, y, cancelScroll)

            'Record current control position Y
            _myCurrentPosition = MyBase.ClientRectangle.Y

        End Sub

        ''' <summary>
        ''' OnMouseUp Event
        ''' </summary>
        ''' <param name="x"></param>
        ''' <param name="y"></param>
        ''' <remarks></remarks>
        Public Overrides Sub OnMouseUp(ByVal x As Integer, ByVal y As Integer)
            MyBase.OnMouseUp(x, y)

            'Check controls current position
            If Not MyBase.ClientRectangle.Y = _myCurrentPosition Then

                'Raise OnControlMoved Event
                RaiseEvent OnControlMoved(Me, MyBase.ClientRectangle.Y)

                'Then exit sub to avoid raising other events
                Exit Sub

            End If

            'Raise OnClick Event before other events first
            RaiseEvent OnClick(Me)

            'Hold Mouse click cordinates
            Dim mousePoint As System.Drawing.Point = System.Windows.Forms.Control.MousePosition()
            Dim pointX As Integer = mousePoint.X - MyBase.ClientRectangle.X
            Dim pointY As Integer = (mousePoint.Y - (Screen.PrimaryScreen.Bounds.Height - DrawingCE.Resolution.ScreenHeight)) - ClientRectangle.Top

            If Not _iThumbnailLeft Is Nothing Then

                Select Case pointX

                    Case _iThumbnailLeftRectangle.Left To _iThumbnailLeftRectangle.Width

                        Select Case pointY

                            Case _iThumbnailLeftRectangle.Top - ClientRectangle.Top To (_iThumbnailLeftRectangle.Top - ClientRectangle.Top) + _iThumbnailLeftRectangle.Height

                                'Raise OnClickiThumbnailLeft Event
                                RaiseEvent OnClickiThumbnailLeft(Me)

                        End Select

                End Select

            End If

            If Not _iThumbnailRight Is Nothing Then

                Select Case pointX

                    Case _iThumbnailRightRectangle.Left To _iThumbnailRightRectangle.Left + _iThumbnailRightRectangle.Width

                        Select Case pointY

                            Case _iThumbnailRightRectangle.Top - ClientRectangle.Top To (_iThumbnailRightRectangle.Top - ClientRectangle.Top) + _iThumbnailRightRectangle.Height

                                'Raise OnClickiThumbnailRight Event
                                RaiseEvent OnClickiThumbnailRight(Me)

                        End Select

                End Select

            End If

            Select Case _primaryText

                Case Nothing, String.Empty,""
                Case Else
                    Select Case pointX

                        Case _primaryTextRectangle.Left To _primaryTextRectangle.Left + _primaryTextRectangle.Width

                            Select Case pointY

                                Case _primaryTextRectangle.Top To _primaryTextRectangle.Top + _primaryTextRectangle.Height

                                    'Raise OnClickPrimaryText Event
                                    RaiseEvent OnClickPrimaryText(Me)

                            End Select

                    End Select
            End Select

            Select Case _secondaryText

                Case Nothing, String.Empty, ""
                Case Else
                    Select Case pointX

                        Case _secondaryTextRectangle.Left To _secondaryTextRectangle.Left + _secondaryTextRectangle.Width

                            Select Case pointY

                                Case _secondaryTextRectangle.Top To _secondaryTextRectangle.Top + _secondaryTextRectangle.Height

                                    'Raise OnClickSecondaryText Event
                                    RaiseEvent OnClickSecondaryText(Me)

                            End Select

                    End Select
            End Select

            Select Case _footerText

                Case Nothing, String.Empty, ""
                Case Else
                    Select Case pointX

                        Case _footerTextRectangle.Left To _footerTextRectangle.Left + _footerTextRectangle.Width

                            Select Case pointY

                                Case _footerTextRectangle.Top To _footerTextRectangle.Top + _footerTextRectangle.Height

                                    'Raise OnClickFooterText Event
                                    RaiseEvent OnClickFooterText(Me)

                            End Select

                    End Select
            End Select

        End Sub

        ''' <summary>
        ''' Draw_HTCContactsStyle3
        ''' </summary>
        ''' <param name="g"></param>
        ''' <remarks></remarks>
        Public Sub Draw_HTCContactsStyle3(ByVal g As System.Drawing.Graphics)

            If Not _iThumbnailLeft Is Nothing Then

                _iThumbnailLeftRectangle = New Rectangle(ClientRectangle.Left + If(_isVGA, 10, 5), ClientRectangle.Top + If(_isVGA, 10, 5), SenseAPIs.SenseImage.GetIImageSize(_iThumbnailLeft).Width, SenseAPIs.SenseImage.GetIImageSize(_iThumbnailLeft).Height)
                _iThumbnailLeftMarginTB = If(_isVGA, 10, 5)
                _iThumbnailLeftMarginLR = If(_isVGA, 10, 5)

                Dim ___iThumbnailLeft As IImage = _iThumbnailLeft
                g.DrawImageAlphaChannel(___iThumbnailLeft, New Rectangle(CInt(_iThumbnailLeftRectangle.Left), CInt(_iThumbnailLeftRectangle.Top), _iThumbnailLeftRectangle.Width, _iThumbnailLeftRectangle.Height))

            End If

            If Not _iThumbnailRight Is Nothing Then

                _iThumbnailRightRectangle = New Rectangle(Screen.PrimaryScreen.Bounds.Width - (SenseAPIs.SenseImage.GetIImageSize(_iThumbnailRight).Width + If(_isVGA, 10, 5)), ClientRectangle.Top + If(_isVGA, 10, 5), SenseAPIs.SenseImage.GetIImageSize(_iThumbnailRight).Width, SenseAPIs.SenseImage.GetIImageSize(_iThumbnailRight).Height)
                _iThumbnailRightMarginTB = If(_isVGA, 10, 5)
                _iThumbnailRightMarginLR = If(_isVGA, 10, 5)

                Dim ___iThumbnailRight As IImage = _iThumbnailRight
                g.DrawImageAlphaChannel(___iThumbnailRight, New Rectangle(CInt(_iThumbnailRightRectangle.Left), CInt(_iThumbnailRightRectangle.Top), _iThumbnailRightRectangle.Width, _iThumbnailRightRectangle.Height))

            End If

            If _primaryText Is Nothing And _secondaryText Is Nothing And _footerText Is Nothing Then Exit Sub

            If _iThumbnailLeft Is Nothing And _iThumbnailRight Is Nothing Then

                If Not _primaryText = String.Empty Then _primaryTextRectangle = _propertyTableValues._primaryTextRectangle
                If Not _secondaryText = String.Empty Then _secondaryTextRectangle = _propertyTableValues._secondaryTextRectangle
                If Not _footerText = String.Empty Then _footerTextRectangle = _propertyTableValues._footerTextRectangle

            End If

            If Not _iThumbnailLeft Is Nothing And Not _iThumbnailRight Is Nothing Then

                If Not _primaryText = String.Empty Then _primaryTextRectangle = _propertyTableValues._primaryTextRectangle
                If Not _secondaryText = String.Empty Then _secondaryTextRectangle = _propertyTableValues._secondaryTextRectangle
                If Not _footerText = String.Empty Then _footerTextRectangle = _propertyTableValues._footerTextRectangle

            End If

            If Not _iThumbnailLeft Is Nothing And _iThumbnailRight Is Nothing Then

                If Not _primaryText = String.Empty Then _primaryTextRectangle = _propertyTableValues._primaryTextRectangle
                If Not _secondaryText = String.Empty Then _secondaryTextRectangle = _propertyTableValues._secondaryTextRectangle
                If Not _footerText = String.Empty Then _footerTextRectangle = _propertyTableValues._footerTextRectangle

            End If

            If _iThumbnailLeft Is Nothing And Not _iThumbnailRight Is Nothing Then

                If Not _primaryText = String.Empty Then _primaryTextRectangle = _propertyTableValues._primaryTextRectangle
                If Not _secondaryText = String.Empty Then _secondaryTextRectangle = _propertyTableValues._secondaryTextRectangle
                If Not _footerText = String.Empty Then _footerTextRectangle = _propertyTableValues._footerTextRectangle

            End If

            If Not _primaryText = String.Empty Then
                'Draw the Primary text with other properties like height,color,style,alignment,etc
                Using f As Font = New Font(_primaryTextFontName, _primaryTextFontSize, _primaryTextFontStyle)
                    Dim s As String = _primaryText
                    Dim r As Rectangle = New Rectangle(_primaryTextRectangle.Left, ClientRectangle.Top + _primaryTextRectangle.Top, _primaryTextRectangle.Width, _primaryTextRectangle.Height) '(Left,Top,Width,Height)
                    Using b As Brush = New SolidBrush(_primaryTextForeColor)
                        Using sf As StringFormat = New StringFormat()
                            sf.Alignment = _primaryTextAlignment
                            g.DrawString(s, f, b, r, sf)
                        End Using
                    End Using
                End Using
            End If

            If Not _secondaryText = String.Empty Then
                'Draw the Secondary text with other properties like height,color,style,alignment,etc
                Using f As Font = New Font(_secondaryTextFontName, _secondaryTextFontSize, _secondaryTextFontStyle)
                    Dim s As String = _secondaryText
                    Dim r As Rectangle = New Rectangle(_secondaryTextRectangle.Left, ClientRectangle.Top + _secondaryTextRectangle.Top, _secondaryTextRectangle.Width, _secondaryTextRectangle.Height) '(Left,Top,Width,Height)
                    Using b As Brush = New SolidBrush(_secondaryTextForeColor)
                        Using sf As StringFormat = New StringFormat()
                            sf.Alignment = _secondaryTextAlignment
                            g.DrawString(s, f, b, r, sf)
                        End Using
                    End Using
                End Using
            End If

            If Not _footerText = String.Empty Then
                'Draw the Footer text with other properties like height,color,style,alignment,etc
                Using f As Font = New Font(_footerTextFontName, _footerTextFontSize, _footerTextFontStyle)
                    Dim s As String = _footerText
                    Dim r As Rectangle = New Rectangle(_footerTextRectangle.Left, ClientRectangle.Top + _footerTextRectangle.Top, _footerTextRectangle.Width, _footerTextRectangle.Height) '(Left,Top,Width,Height)
                    Using b As Brush = New SolidBrush(_footerTextForeColor)
                        Using sf As StringFormat = New StringFormat()
                            sf.Alignment = _footerTextAlignment
                            g.DrawString(s, f, b, r, sf)
                        End Using
                    End Using
                End Using
            End If

        End Sub

        ''' <summary>
        ''' OnRender
        ''' </summary>
        ''' <param name="g"></param>
        ''' <remarks></remarks>
        Public Overrides Sub OnRender(ByVal g As System.Drawing.Graphics)
            MyBase.OnRender(g)

            Try

                Draw_HTCContactsStyle3(g)

            Catch ex As Exception

                'Throw exception if any other error caught
                Throw New Exception(ex.Message)

            End Try

        End Sub

#End Region

#Region "Properties"

        ''' <summary>
        ''' Primary Text
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryText() As String
            Get
                Return _primaryText
            End Get
            Set(ByVal value As String)
                _primaryText = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextFontName
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextFontName() As String
            Get
                Return _primaryTextFontName
            End Get
            Set(ByVal value As String)
                _primaryTextFontName = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextFontSize
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextFontSize() As Single
            Get
                Return _primaryTextFontSize
            End Get
            Set(ByVal value As Single)
                _primaryTextFontSize = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextFontStyle
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextFontStyle() As System.Drawing.FontStyle
            Get
                Return _primaryTextFontStyle
            End Get
            Set(ByVal value As System.Drawing.FontStyle)
                _primaryTextFontStyle = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextForeColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextForeColor() As System.Drawing.Color
            Get
                Return _primaryTextForeColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _primaryTextForeColor = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextBackColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextBackColor() As System.Drawing.Color
            Get
                Return _primaryTextBackColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _primaryTextBackColor = value
            End Set
        End Property

        ''' <summary>
        ''' PrimaryTextAlignment
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property PrimaryTextAlignment() As System.Drawing.StringAlignment
            Get
                Return _primaryTextAlignment
            End Get
            Set(ByVal value As System.Drawing.StringAlignment)
                _primaryTextAlignment = value
            End Set
        End Property

        ''' <summary>
        ''' Secondary Text
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryText() As String
            Get
                Return _secondaryText
            End Get
            Set(ByVal value As String)
                _secondaryText = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextFontName
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextFontName() As String
            Get
                Return _secondaryTextFontName
            End Get
            Set(ByVal value As String)
                _secondaryTextFontName = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextFontSize
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextFontSize() As Single
            Get
                Return _secondaryTextFontSize
            End Get
            Set(ByVal value As Single)
                _secondaryTextFontSize = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextFontStyle
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextFontStyle() As System.Drawing.FontStyle
            Get
                Return _secondaryTextFontStyle
            End Get
            Set(ByVal value As System.Drawing.FontStyle)
                _secondaryTextFontStyle = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextForeColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextForeColor() As System.Drawing.Color
            Get
                Return _secondaryTextForeColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _secondaryTextForeColor = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextBackColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextBackColor() As System.Drawing.Color
            Get
                Return _secondaryTextBackColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _secondaryTextBackColor = value
            End Set
        End Property

        ''' <summary>
        ''' SecondaryTextAlignment
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property SecondaryTextAlignment() As System.Drawing.StringAlignment
            Get
                Return _secondaryTextAlignment
            End Get
            Set(ByVal value As System.Drawing.StringAlignment)
                _secondaryTextAlignment = value
            End Set
        End Property

        ''' <summary>
        ''' Footer Text
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterText() As String
            Get
                Return _footerText
            End Get
            Set(ByVal value As String)
                _footerText = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextFontName
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextFontName() As String
            Get
                Return _footerTextFontName
            End Get
            Set(ByVal value As String)
                _footerTextFontName = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextFontSize
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextFontSize() As Single
            Get
                Return _footerTextFontSize
            End Get
            Set(ByVal value As Single)
                _footerTextFontSize = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextFontStyle
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextFontStyle() As System.Drawing.FontStyle
            Get
                Return _footerTextFontStyle
            End Get
            Set(ByVal value As System.Drawing.FontStyle)
                _footerTextFontStyle = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextForeColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextForeColor() As System.Drawing.Color
            Get
                Return _footerTextForeColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _footerTextForeColor = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextBackColor
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextBackColor() As System.Drawing.Color
            Get
                Return _footerTextBackColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                _footerTextBackColor = value
            End Set
        End Property

        ''' <summary>
        ''' FooterTextAlignment
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property FooterTextAlignment() As System.Drawing.StringAlignment
            Get
                Return _footerTextAlignment
            End Get
            Set(ByVal value As System.Drawing.StringAlignment)
                _footerTextAlignment = value
            End Set
        End Property

        ''' <summary>
        ''' iThumbnailLeft
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <CLSCompliant(False)> _
        Public Property iThumbnailLeft() As Microsoft.Drawing.IImage
            Get
                Return _iThumbnailLeft
            End Get
            Set(ByVal value As Microsoft.Drawing.IImage)
                _iThumbnailLeft = value
            End Set
        End Property

        ''' <summary>
        ''' iThumbnailRight
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <CLSCompliant(False)> _
        Public Property iThumbnailRight() As Microsoft.Drawing.IImage
            Get
                Return _iThumbnailRight
            End Get
            Set(ByVal value As Microsoft.Drawing.IImage)
                _iThumbnailRight = value
            End Set
        End Property

        ''' <summary>
        ''' PropertyTable
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <CLSCompliant(False)> _
        Public Property PropertyTable() As SenseAPIsEx.SenseControlsManager.PropertyTableValues
            Get
                Return _propertyTableValues
            End Get
            Set(ByVal value As SenseAPIsEx.SenseControlsManager.PropertyTableValues)
                MyBase.Height = value._size.Height
                _propertyTableValues = value
            End Set
        End Property

#End Region

    End Class

End Namespace